<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="button" value="请求员工数据">
<table border="1">
  <caption>员工列表</caption><!--caption标题-->
  <tr>
    <th>姓名</th><!--th表头-->
    <th>工资</th>
    <th>工作</th>
  </tr>
</table>
<!--引入jQuery框架-->
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script>
  //JavaScript中的对象
  let obj1 = {} //空对象
  let obj2 = {name:"tom",age:18}; //带属性的对象
  let obj3 = {
    name:"刘德华",
    run:function () {
      alert("我叫"+this.name)
    }
  }   //带属性和方法的对象
  obj3.run();//调用对象里面的方法
  let emp = {name:"刘备",salary:5000,job:"销售"};// 表示一个员工对象
  let arr = [{name:"刘备",salary:5000,job:"销售"},
    {name:"关羽",salary:2000,job:"人事"},
    {name:"张飞",salary:1000,job:"程序员"}]//表示一个数组里面装了多个员工对象
  $("input").click(function () {
    //滑舌数组是从服务器中请求到数据
    let arr = [{name:"刘备",salary:5000,job:"销售"},
      {name:"关羽",salary:2000,job:"人事"},
      {name:"张飞",salary:1000,job:"程序员"}]//表示一个数组里面装了多个员工对象
    //遍历数组中的元素对象
    for (let e of arr) {
      let tr = $("<tr></tr>");
      let nameTd = $("<td></td>");nameTd.text(e.name);
      let salTd = $("<td></td>");salTd.text(e.salary);
      let jobTd = $("<td></td>");jobTd.text(e.job);
      tr.append(nameTd);
      tr.append(salTd);
      tr.append(jobTd);//把td装进tr

      $("table").append(tr);//把tr装进table
    }
  })
</script>
</body>
</html>